import {reqOrderInitiate, reqQueryDetail} from "@/api";

const state = {
    //订单列表数据
    orderInitiate:{},

    //订单详情数据
    orderDetailInfo:{},
    //用户信息详情
    userDetail:{},
};
const actions = {
    async OrderInitiate({commit},query) {
        //向服务器发送请求，获取求助订单数据
        let resultOrderInitiate = await reqOrderInitiate(query.params,query.queryOrderInitiate);
        commit("OrderInitiate",resultOrderInitiate)
    },
    async OrderDetail({commit},orderId){
        let resultOrderDetail = await reqQueryDetail(orderId)
        commit("OrderDetailInfo",resultOrderDetail)
    },
    //根据标题搜索
    async reqSearch({dispatch,commit},title) {
        let query;
        query={params: {pageNo: 1, pageSize: 10},queryOrderInitiate:{schoolId:undefined,
                campusId:undefined,
                labelId:undefined,
                orderDate:undefined,
                orderStartTime:undefined,
                orderEndTime:undefined,
                creditScore:undefined,
                title:undefined,}}
        query.queryOrderInitiate.title = title
        dispatch('OrderInitiate',query)
    }
};
const mutations = {
    OrderInitiate(state,orderInitiate){
        state.orderInitiate = orderInitiate
    },
    OrderDetailInfo(state,orderDetail){
        state.orderDetailInfo = orderDetail
        state.userDetail = orderDetail.user
    }
};
const getters = {};
export default {
    state,
    mutations,
    actions,
    getters
}
